package com.mydemo.springlearning.common.filter;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author hd
 * @date 2022/2/8 16:02
 */
@Slf4j
@WebFilter(filterName = "requestLifecycleFilter", urlPatterns = "/*")
public class RequestLifecycleFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.warn("RequestLifecycleFilter-->>> init");
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.warn("RequestLifecycleFilter-->>> do filter");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        log.warn("RequestLifecycleFilter-->>> destroy");
        Filter.super.destroy();
    }
}
